package com.chase.framerwork.util;

import org.springframework.beans.BeansException;
import org.springframework.context.ApplicationContext;
import org.springframework.context.ApplicationContextAware;

/**
 * Spring工具类
 * 
 * @Author Chase
 * @Date 2013-10-13
 */
public class SpringUtil implements ApplicationContextAware
{

	/**
	 * Spring上下文
	 */
	private static ApplicationContext applicationContext;

	/**
	 * 设置当前上下文环境，此方法由spring自动装配
	 */
	@Override
	public void setApplicationContext(ApplicationContext applicationContext) throws BeansException
	{
		SpringUtil.applicationContext = applicationContext;
	}

	/**
	 * 从当前上下文中获取bean
	 * 
	 * @param id
	 * 
	 * @return
	 */
	public static Object getBean(String id)
	{
		Object object = applicationContext.getBean(id);
		return object;
	}
}